#!/bin/sh

export LIB=jpgbmp
export CFLG="-D___SYS_I486 -D___OS_LIN"
export GFLG="-D___GUI"
export OBJS="std.c jpeg1.c jpeg2.c bmp.c"
export OBJS="$OBJS huf.c dct.c"
export LIBS="-lm -ldl -lpthread"
export LIBS="$LIBS -lgcc -lc -lgcc"

if [ "$1" == "-g" ]; then
  export CFLG="$CFLG $GFLG"
  shift
fi
if [ "$1" == "-ropt" ]; then
  export CFLG="$CFLG -D___ROPT"
  shift
fi

echo CFLG=$CFLG
gcc -s -O2 -Wall -c $CFLG $OBJS ; ar -r lib$LIB.a *.o
gcc -s -O2 -Wall -o lib$LIB-dll.so -shared $CFLG $OBJS $LIBS
